#include <stdio.h>
#include <stdlib.h>


void bubble_sort(int nums[] ,int n)
{
    int i ,temp;
    int flag = 0;
    for(i=0; i<n-1; i++)
    {
        int j;
        for(j=0; j<n-1-i; j++)
        {
            if(nums[j] > nums[j+1])
            {
                temp = nums[j];
                nums[j] = nums[j+1];
                nums[j+1] = temp;
                flag = 1;
            }
        }
        if(flag == 0)
            break;
    }
}




int main()
{
    //int n = 8;
    int arr[] = {2,3,1,5,4,8,2,4};
    int n = sizeof(arr)/4;
    int i = 0;
    for(i=0; i<n; i++)
    {
        printf("arr[%d]=%d\n",i,arr[i]);
    }
    printf("arr nums = %d\n",n);
    bubble_sort(arr, n);
    for(i=0; i<n; i++)
    {
        printf("arr[%d]=%d\n",i,arr[i]);
    }


}